//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "Base/Platform/Device.h"
#include "Base/Platform/DeviceEmulator.h"

namespace Engine
{
namespace Platforms
{
	using namespace Base;



	//
	// Display Wrapper
	//

	struct DisplayWrap : Display
	{
		void SetResolution (const ivec2 &res)				{ SetterGetter::SetResolution( *this, ScreenCoords::Pixels( res ) ); }
		void SetPhysicalSize (const vec2 &size)				{ _size = ScreenCoords::Physics( size ); }
		void SetPPI (uint ppi)								{ _ppi = ppi; }
		void SetOrientation (EOrientation orient)			{ _orient = orient; }

		ivec2 const &	GetRawResolution ()	const			{ return _res.Get(); }

		DisplayWrap &	operator = (const Display &right)
		{
			DisplayWrap const &	r = (DisplayWrap const &) right;

			_res		= r._res;
			_size		= r._size;
			_ppi		= r._ppi;
			_orient		= r._orient;

			return *this;
		}
	};



	//
	// Device Wrapper
	//

	struct DeviceWrap : Device
	{
		void SetDisplay (const Display &disp)				{ _display = disp; }
		void SetDeviceName (uni_c_string value)				{ _name = value; }
		void SetOSName (uni_c_string value)					{ _os = value; }
		void SetGPUName (uni_c_string value)				{ _gpu = value; }
		void SetDeviceID (uni_c_string id)					{ _deviceID = id; }
		void SetPackage (uni_c_string pac)					{ _package = pac; }

		void SetNumCPUs (uint value)						{ _numCPUs = value; }
		void SetCpuFreq (uint value)						{ _cpuFreq = value; }
		void SetTotalRAM (Bytes value)						{ _totalMem = value; }

		DisplayWrap &	GetDisplayRef ()					{ return (DisplayWrap &) _display; }
		
		void SetLocale (uni_c_string value)
		{
			if ( value.Length() == 2 )
			{
				_iso2Locale.Copy( uni_array<const char>( value ) );
				_iso3Locale = LocaleUtils::Iso2ToIso3( _iso2Locale );
			}
			else
			if ( value.Length() == 3 )
			{
				_iso3Locale.Copy( uni_array<const char>( value ) );
				_iso2Locale = LocaleUtils::Iso3ToIso2( _iso3Locale );
			}
			else
			{
				_iso2Locale.Clear();
				_iso3Locale.Clear();
				WARNING( "unknown locale type!" );
			}
		}

		DeviceWrap &	operator = (const Device &right)
		{
			DeviceWrap const &	r = (DeviceWrap const &) right;

			_display	= r._display;
			_deviceID	= r._deviceID;
			_name		= r._name;
			_os			= r._os;
			_gpu		= r._gpu;
			_package	= r._package;
			_numCPUs	= r._numCPUs;
			_cpuFreq	= r._cpuFreq;
			_totalMem	= r._totalMem;
			_iso2Locale	= r._iso2Locale;
			_iso3Locale	= r._iso3Locale;

			return *this;
		}
	};


}	// Platforms
}	// Engine